/* Project cyclecounter_osc
PIC16F628A
*/
#include <pic.h>
__CONFIG(
PWRTEN
& BORDIS
& UNPROTECT
& WDTDIS
& LVPDIS
& HS
);
__IDLOC(F628);
#define CK RB0
#define RES RB1
#define SW1 RB2
#define SW2 RB4
#define SW3 RB5
unsigned char i, N;
void interrupt entry(void){
if(TMR1IF){
TMR1IF = 0;
N ++;
if(SW1){
TMR1H = 158; TMR1L = 126;
if(N > 9){
N = 0;
CK = 1;
NOP();
CK = 0;
NOP();
RES = 1;
NOP();
RES = 0;
TMR1H = 157; TMR1L = 239;
}
} else
if(SW2){
CK = 1;
NOP();
CK = 0;
NOP();
RES = 1;
NOP();
RES = 0;
for(i=0; i<10; i++){
NOP();
}
TMR1H = 158; TMR1L = 202;
} else
if(SW3){
CK = 1;
NOP();
CK = 0;
NOP();
RES = 1;
NOP();
RES = 0;
NOP();NOP();
TMR1H = 246; TMR1L = 91;
}
}
}
void main(void){
CMCON = 0b00000111;
T1CON = 0b00000001;
PIE1 = 0b00000001;
INTCON = 0b01000000;
TMR1IF = 0;
ei();
PR2 = 153;
T2CON = 0b00000110;
CCPR1L = 75;
CCP1CON = 0b00001100;
OPTION = 0b10000000;
PORTA = 0;
TRISA = 0b00000000;
PORTB = 0;
TRISB = 0b00110100;
N = 0;
while(1){
}
}